Documentation for Users  2.1.2
Perception Toolbox for Virtual Reality (PTVR) Manual
reticle.py
Go to the documentation of this file.
1 # -*- coding: utf-8 -*-
2 """
3 ...\PTVR_Researchers\Python_Scripts\Demos\Pointing\reticle.py
4 
5 Goal of this demo:
6  Show the simplest way of creating a standard PTVR
7  contingent reticle.
8  In this demo, the reticle is head-contingent (i.e. it moves with
9  your head) - this is also known as being head-controlled.
10 
11 
12 Note 1 : By default, the reticle is White. This is perfect when the
13  (average) background is dark (as in the present demo.
14  If the (average) background were luminous, you could
15  set the reticle's color to black
16  (cf. 'color 'parameter in ReticleImageFromDrawing() )
17 
18 Note 2: If the background is dark in some locations and bright in other
19  locations, the best choice is to use the BICOLOR RETICLE by
20  setting the 'two_colors' parameter to True in ReticleImageFromDrawing().
21  The BICOLOR reticle is made of two contours (white and black),
22  which makes it ideal for a background containing dark and bright patches
23  of colors.
24 
25  To illustrate the use of the BICOLOR RETICLE, have a look at the
26  "reticle_on_different_bckgnd_colors.py" demo.
27 
28 Note 3: The reticle belongs to the PTVR category called "flat cursors".
29 
30 
31 """
32 
33 from PTVR.Visual import The3DWorld
34 from PTVR.Stimuli.Scenes import VisualScene
35 from PTVR.Pointing.PointingCursor import *
37 from PTVR.SystemUtils import LaunchThe3DWorld
38 
39 my_contingency = ImageContingency.HEADSET
40 
41 my_world = The3DWorld()
42 
43 def main():
44 
45  my_scene = VisualScene (skybox = "Night") # "Night", "BrightMorning", "Cloudy",
46  # "Afternoon", "Sunset"
47 
48  reticle_2D_image = RG.ReticleImageFromDrawing()
49 
50  # If you want to open a window on your PC showing the reticle image
51  # that has just been internally drawn, comment out the following line.
52  # reticle_2D_image.Show()
53 
54  # transform 'reticle_2D_image' into a contingent cursor.
55  my_reticle = ImageToContingentCursor(
56  image = reticle_2D_image,
57  contingency_type = my_contingency)
58 
59  my_scene.place_contingent_cursor(my_reticle)
60 
61  my_world.add_scene(my_scene)
62  my_world.write()
63 
64 if __name__ == "__main__":
65  main()
66  LaunchThe3DWorld() # Launch the Experiment with PTVR.
def LaunchThe3DWorld(jsonFileCategory="Externals")
Definition: SystemUtils.py:182
def main()
Definition: reticle.py:43